/*
 * Copyright (c) 2008 Golden T Studios.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.golden.gamedev.object;

import java.io.Serializable;

import com.golden.gamedev.ActionExecutor;
import com.golden.gamedev.NullActionExecutor;
import com.golden.gamedev.engine.timer.SerializableTimer;

/**
 * Class to manage timing in GTGE Frame Work to create game independent of frame
 * rate. <code>Timer</code> is usually used to create sprite behaviour, such as
 * used in sprite animation.
 * <p>
 * 
 * Example how to use timer in conjunction with sprite in order to make the
 * sprite do an action every 1 second :
 * 
 * <pre>
 * public class DummySprite extends Sprite {
 *     // 1000 ms = 1 sec
 *     Timer timer = new Timer(1000);
 *     public void update(long elapsedTime) {
 *       if (timer.action(elapsedTime)) {
 *         // do an action!! this always called every 1 second
 *       }
 *     }
 *   }
 * }
 * </pre>
 * @deprecated The {@link Timer} class is now deprecated and will be removed in
 *             0.2.5 - use {@link SerializableTimer} as a direct replacement for
 *             its functionality.
 */
public class Timer extends SerializableTimer {
	
	/**
	 * {@link Serializable} id generated by Eclipse.
	 * @deprecated The {@link Timer} class is now deprecated and will be removed
	 *             in 0.2.5 - use {@link SerializableTimer} as a direct
	 *             replacement for its functionality.
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * Creates a new <code>Timer</code> with specified delay time in
	 * milliseconds.
	 * 
	 * @param delay delay time in milliseconds.
	 * @deprecated This constructor is deprecated and will be removed in 0.2.5.
	 *             Use {@link Timer#Timer(long, ActionExecutor)} with the second
	 *             argument being the {@link NullActionExecutor#INSTANCE} to get
	 *             the same effect as this constructor, but it is recommended to
	 *             not examine the result of {@link #action(long)}, but to
	 *             simply construct a {@link Timer} with the
	 *             {@link ActionExecutor} that it should
	 *             {@link ActionExecutor#execute() execute} immediately before
	 *             {@link #action(long)} returns true. This constructor is also
	 *             deprecated because it sets the delay as an integer, when it
	 *             is represented properly as a long. The {@link Timer} class is
	 *             now deprecated and will be removed in 0.2.5 - use
	 *             {@link SerializableTimer} as a direct replacement for its
	 *             functionality.
	 */
	public Timer(int delay) {
		super(delay, NullActionExecutor.INSTANCE);
	}
	
	/**
	 * Creates a new {@link Timer} instance with the specified delay time in
	 * milliseconds and the non-null {@link ActionExecutor} instance to invoke
	 * immediately before {@link #action(long)} returns true.
	 * @param delay The delay time, in milliseconds.
	 * @param executor The non-null {@link ActionExecutor} instance to invoke
	 *        immediately before {@link #action(long)} returns true.
	 * @throws IllegalArgumentException Throws an
	 *         {@link IllegalArgumentException} if the given
	 *         {@link ActionExecutor} instance is null.
	 * @deprecated The {@link Timer} class is now deprecated and will be removed
	 *             in 0.2.5 - use {@link SerializableTimer} as a direct
	 *             replacement for its functionality.
	 */
	public Timer(long delay, final ActionExecutor executor) {
		super(delay, executor);
	}
}
